﻿package Gameplay
{	
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.geom.ColorTransform;

	public class FlashStrip extends MovieClip 
	{
		private static const SHOW_TIME:Number = 6;
		
		public var ID:int;
		private var FCounter:int;
		private var FRedTransform:ColorTransform;
		private var FGreenTransform:ColorTransform;
		private var FLamp:MovieClip;
		
		public function FlashStrip() 
		{
			FCounter = 0;
			visible = true;
			alpha = 0;
			FGreenTransform = transform.colorTransform;
			FRedTransform = new ColorTransform();			
			FRedTransform.color = 0xFF0000;
			addEventListener(Event.ENTER_FRAME, OnEnterFrame);
		}
		
		public function set Lamp(ALamp:MovieClip):void
		{
			FLamp = ALamp;
			FLamp.visible = false;
		}
		
		public function Show(AGreen:Boolean):void
		{
			FLamp.visible = true;			
			if(!AGreen)
				transform.colorTransform = FRedTransform;
			else
				transform.colorTransform = FGreenTransform;
			alpha = 1;
		}
		
		private function OnEnterFrame(e:Event)
		{
			if(alpha > 0)
			{
				if(FCounter < SHOW_TIME)
				{
					FCounter++;
				}
				else
				{
					alpha = 0;
					FLamp.visible = false;
					FCounter = 0;
				}
			}
		}
	}	
}
